﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace TR0217.ControlEx
{
    [ToolboxBitmap(typeof(ComboBox))]
    public class ComboBox22:ComboBox
    {
        public ComboBox22()
            : base()
        {
            base.DrawMode = DrawMode.OwnerDrawFixed;
        }


        [Browsable(false)]
        public new DrawMode DrawMode
        {
            get { return base.DrawMode; }
            set { ;}
        }

        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            StringFormat format = new StringFormat();
            Brush fbrush = new SolidBrush(e.ForeColor);
            format.FormatFlags = StringFormatFlags.NoClip;
            e.DrawBackground();
            if (e.Index < 0)
            {
                e.Graphics.DrawString(this.Text, this.Font, fbrush, e.Bounds, format);
            }
            else
            {
                e.Graphics.DrawString(base.Items[e.Index].ToString(), e.Font, fbrush, e.Bounds, format);
            }
            e.DrawFocusRectangle();
            fbrush.Dispose();
            format.Dispose();
        }
    }
}
